﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TravelLink.WebModel;
using System.Text;

namespace TravelLink.WebApp.UserControl {
    public partial class UC_Nav : ControlBase, ISetNav {
        protected void Page_Load(object sender, EventArgs e) {

        }

        public void SetNav(Queue<NavItem> navs) {
            NavItem current = null;
            int i = 0;
            int max = navs.Count - 1;
            StringBuilder str = new StringBuilder();
            while (navs != null && navs.Count > 0) {
                current = navs.Dequeue();
                if (i == max)
                    str.AppendFormat("&nbsp;&nbsp;&nbsp;&nbsp;<a href='{0}'>{1}</a>", current.Url, current.Title);
                else if (i == 0)
                    str.AppendFormat("<a href='{0}'>{1}</a>", current.Url, current.Title).Append("&nbsp;&nbsp;&nbsp;&nbsp;|");
                else
                    str.AppendFormat("<a href='{0}'>{1}</a>", current.Url, "&nbsp;&nbsp;&nbsp;&nbsp;" + current.Title + "&nbsp;&nbsp;&nbsp;&nbsp;|");
                i++;
            }

            ltHtml.Text = str.ToString();
        }
    }
}